Skip to content

Fix crash when selecting a repo with no branches#331

Merged
brendanlong merged 2 commits intomainfrom
claude/5f46b5be-1369-4f53-b4f8-fb6c07568a87
Apr 10, 2026
Merged

Fix crash when selecting a repo with no branches#331
brendanlong merged 2 commits intomainfrom
claude/5f46b5be-1369-4f53-b4f8-fb6c07568a87

Conversation

@brendanlong
Copy link
Copy Markdown
Owner

Summary

  • When selecting a newly created repo (like brendanlong/personal-agent-skills) with no branches, the New Session page would crash
  • The GitHub API returns {"branches":[],"defaultBranch":"main"} — BranchSelector would auto-select "main" even though it didn't exist in the empty branches list, causing the Select component to crash
  • Now checks that defaultBranch actually exists in the branches array before auto-selecting
  • Shows a "No branches found" message when the branches list is empty

Test plan

  • All 362 existing tests pass
  • Select a repo with no branches — should show "No branches found" instead of crashing
  • Select a repo with branches — should auto-select default branch as before

🤖 Generated with Claude Code

When the GitHub API returns an empty branches array (e.g. for a newly
created repo), BranchSelector would auto-select the defaultBranch even
though it didn't exist in the list. This caused the Select component to
receive a value with no matching SelectItem, crashing the page.

Now we check that the defaultBranch exists in the branches array before
auto-selecting, and show a helpful message when no branches are found.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the BranchSelector component by ensuring the default branch is only selected if it exists within the retrieved branch list and by adding a user-friendly message when no branches are found. A review comment identifies a potential performance issue where including a derived array in the useEffect dependency array could cause unnecessary re-renders, suggesting a more direct access to the data object instead.

Use data.branches directly inside the effect instead of the derived
branches variable. Since branches is recomputed as a new [] on every
render when data is undefined, including it in the dependency array
caused unnecessary effect re-runs during loading.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@brendanlong brendanlong merged commit eb4413b into main Apr 10, 2026
4 checks passed
@brendanlong brendanlong deleted the claude/5f46b5be-1369-4f53-b4f8-fb6c07568a87 branch April 10, 2026 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants